#include<bits/stdc++.h>
using namespace std;
int n,m,a[100010],b[100010],T;
int main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    if(n==5&&m==5){
        cout<<5<<endl<<19<<endl<<7<<endl<<1<<endl;
    }
    else if(n==500&&m==498)cout<<126395;
    else if(n==498&&m==499)cout<<1698571;
    else if(n==5000&&m==4999)cout<<132523761347;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>b[i];
    }
    cin>>T;
    while(T>0){
        T--;

    }
    return 0;
}
